package com.xcity.game.activity2.circle;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Binding;
import naga.x.game.template.annotation.Excel;

/**
 * 积分兑换
 * @author shipeng.zhu
 *
 */
@Excel(value = "circle.xlsx", sheetName = "积分兑换")
public class CircleShopTemplate extends Template {

	/** 类型(1金钱 2物品) */
	protected int type;

	/** 物品ID */
	protected int itemId;

	/** 物品图标 */
	protected String itemIcon;

	/** 物品数量 */
	protected int itemCount;

	/** 花费积分 */
	protected int price;
	
	/** 兑换次数限制 */
	protected int limitCount;
	
	/** 商店类型 */
	protected int shopType;

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getItemId() {
		return itemId;
	}

	public void setItemId(int itemId) {
		this.itemId = itemId;
	}

	public String getItemIcon() {
		return itemIcon;
	}

	public void setItemIcon(String itemIcon) {
		this.itemIcon = itemIcon;
	}

	public int getItemCount() {
		return itemCount;
	}

	public void setItemCount(int itemCount) {
		this.itemCount = itemCount;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public int getLimitCount() {
		return limitCount;
	}

	public void setLimitCount(int limitCount) {
		this.limitCount = limitCount;
	}

	public int getShopType() {
		return shopType;
	}

	public void setShopType(int shopType) {
		this.shopType = shopType;
	}

	@Override
	public void validate() throws TemplateException {
		switch(type){
		case 1://钱
			if(itemCount <= 0){
				throw new TemplateException("circle.xlsx欢乐转盘积分商城类型错误->id=" + id);
			}
			if(itemIcon == null || itemIcon.isEmpty()){
				throw new TemplateException("circle.xlsx欢乐转盘积分商城错误图标未配置->id=" + id);
			}
			break;
		case 2://物品
			if(itemId <= 0 || itemCount <= 0){
				throw new TemplateException("circle.xlsx欢乐转盘积分商城类型错误->id=" + id);
			}
			break;
		default:
			throw new TemplateException("circle.xlsx欢乐转盘积分商城类型错误->id=" + id);
		}
	}
}
